<?php
	include "db.php";
	$table = $_POST['table'];
	$result = mysql_query("select * from $table");
	if (!$result) {
		die('Query failed: ' . mysql_error());
	}
	$i = 1;
	$index = 1;
	$update = "";
	$meta = mysql_fetch_field($result, $i);
	$a = $_POST['a'.$index];
	$update = $meta->name."='$a'";
	$i++;
	$index++;
	while ($i < (mysql_num_fields($result)-1)) {
		echo "Information for column $i:<br />\n";
		$meta = mysql_fetch_field($result, $i);
		$col = $meta->name;
		$a = $_POST['a'.$index];
		$update = $update.",$col='$a'";
		$index++;
		$i++;
	}
	//echo $table."<br>";
	//echo "Update = ".$update;
	
	$id = $_POST['a0'];
	$q = "update $table set $update where id = '$id'";
	$rs = mysql_query($q);
	$go = $_SERVER['HTTP_REFERER'];
	header("location:$go");
?>
